package com.fangyi.yunmusic.controller;

import com.fangyi.yunmusic.pojo.Song;
import com.fangyi.yunmusic.pojo.vo.SongVO;
import com.fangyi.yunmusic.service.SongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("song")
public class SongController {

    @Autowired
    private SongService songService;

    @GetMapping("/detail")
    public Object getSongDetailById(String id) {
        return songService.getSongDetail(id);
    }

    @GetMapping("/album")
    public Object getSongVOsByAlbumId(String albumId){
        return songService.selectSongByAlbumId(albumId);
    }
    @GetMapping("/playlist")
    public Object getSongVOsByPlaylistId(String playlistId){
        return songService.selectSongByPlaylistId(playlistId);
    }
    @GetMapping("/artist")
    public Object getSongVOsByArtistId(String artistId){
        return songService.selectSongByArtistId(artistId);
    }

    @PostMapping("/add")
    public Object addSong(Song song, String albumId) {
        songService.addSong(song, albumId);
        return "添加歌曲成功";
    }
    @PostMapping("/delete")
    public Object deleteSong(String songId){
        songService.deleteSong(songId);
        return "歌曲删除成功！";
    }
    @GetMapping("/count")
    public Object getSongCount(){
        return songService.getSongCount();
    }


}
